package com.yeqian.user.controller;

import com.github.pagehelper.PageInfo;
import com.yeqian.entity.ResultJson;
import com.yeqian.user.entity.Permission;
import com.yeqian.user.service.PermissionService;
import com.yeqian.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 权限管理控制器
 */
@Api(tags = "权限管理")
@Slf4j
@RestController
@RequestMapping(Urls.Permission.PERMISSION)
public class PermissionController {

    @Resource
    private PermissionService permissionService;

    /**
     * 查看权限列表
     *
     * @param pageVO
     * @return
     */
    @ApiOperation("查看权限列表")
    @PreAuthorize("hasRole('bmy')")
    @PostMapping(Urls.Permission.LIST_PERMISSION)
    public ResultJson listpermission(@RequestBody PageVO pageVO) {
        PageInfo<Permission> list = permissionService.listpermission(pageVO);
        return ResultJson.Success("查看权限列表成功", list);
    }
}
